package com.ruoyi.common.core.page;

import io.swagger.annotations.ApiModelProperty;

import java.util.ArrayList;
import java.util.List;

/**
 * 分页信息
 *
 * @param <T>
 */
public class PageList<T> {

    @ApiModelProperty(value = "页码，默认1", example = "1", required = true)
    private Integer pageNo = 1;
    @ApiModelProperty(value = "每页记录数，默认10", example = "10", required = true)
    private Integer pageSize = 10;
    @ApiModelProperty(value = "总页数", example = "1", required = true)
    private Integer pageTotal;
    @ApiModelProperty(value = "总记录数", example = "9", required = true)
    private Long total;
    @ApiModelProperty(value = "查询结果集", notes = "查询结果集")
    private List<T> data;

    public Integer getPageNo() {
        return pageNo;
    }

    public void setPageNo(Integer pageNo) {
        this.pageNo = pageNo;
    }

    public PageList() {
        data = new ArrayList<>();
        total = 0L;
        pageTotal = 0;
    }

    public Integer getPageSize() {
        return pageSize;
    }

    public void setPageSize(Integer pageSize) {
        this.pageSize = pageSize;
    }

    public Integer getPageTotal() {
        return pageTotal;
    }

    public void setPageTotal(Integer pageTotal) {
        this.pageTotal = pageTotal;
    }

    public Long getTotal() {
        return total;
    }

    public void setTotal(Long total) {
        this.total = total;
    }

    public List<T> getData() {
        return data;
    }

    public void setData(List<T> data) {
        this.data = data;
    }

    public static PageList createEmpty() {
        PageList pageList = new PageList();
        pageList.setPageTotal(0);
        pageList.setPageNo(0);
        pageList.setPageSize(0);
        pageList.setTotal(0L);
        pageList.setData(new ArrayList<>());
        return pageList;
    }
}
